import axios from 'axios'

export default {
	namespaced: true,
	actions: {
		getAllPage: function ({commit},params) {
			let {callback} = params;
			
			params.onget = ({data}) =>{
				callback(data.page);
			}
			
			commit("getAll",params)
		},
		deletePage: function ({commit},params) {
			let {callback} = params;
			
			params.onget = ({data}) =>{
				callback(data.success);
			}
			
			commit("deletePage",params)
		},
	},
	mutations: {
		getAll: function (state, {title, pageContent, pageTypeId, plateId, userId, page, size, onget}) {
			axios.get('/admin/page',
				{
					params:{
						title,pageContent,pageTypeId,plateId,userId,page,size
					}
				}
			).then((data) => {
				onget(data);
			});
		},
		deletePage: function (state, {id, onget}) {
			axios.delete(`/admin/page`,{params:{id}}).then(data => {
				onget(data);
			});
		},
	}
	
}